﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewSPSites.aspx.cs" Inherits="SPContentDatabaseManager.Layouts.SPContentDatabaseManager.ViewSPSites" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <!-- 
        Copyright 2014, Ryan Dennis
        ryan@sharepointryan.com
        www.sharepointryan.com
        @SharePointRyan on Twitter
        Ryan works for Blue Chip Consulting Group, www.bluechip-llc.com
        All code is provided with no warranty or guarantees.
        Visit the codeplex site: https://spcontentdbmanager.codeplex.com

        Feel free to modify this code, but please leave this section in to give the original author credit.
    -->
    <link rel="Stylesheet" href="SPCDMStyles.css" />
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <table class="spcdm-primaryTableFull" cellpadding="1">
        <tr>
            <td class="ms-standardheader ms-inputformheader spcdm-halfWidth">Web Application</td>
            <td class="ms-authoringcontrols">
                <SharePoint:WebApplicationSelector ID="SelectedWebApplication" runat="server" UseDefaultSelection="true" AllowAdministrationWebApplication="false" OnContextChange="WebAppOnLoad" />
            </td>
        </tr>
        <tr>
            <td class="ms-descriptiontext ms-inputformdescription spcdm-halfWidth">Select a web application.</td>
        </tr>
    </table>
    <table class="spcdm-primaryTableFull" cellpadding="1">
        <tr>
            <td class="ms-standardheader ms-inputformheader spcdm-halfWidth">Content Database</td>
            <td class="ms-authoringcontrols">
                <asp:DropDownList ID="DatabasesForWebApp" runat="server" AutoPostBack="false" OnLoad="FillDatabaseSelector" />
                <asp:Button ID="GetSitesBtn" runat="server" Text="Get Sites" OnClick="OnDbChange" />
            </td>
        </tr>
        <tr>
            <td class="ms-descriptiontext ms-inputformdescription spcdm-halfWidth">Select a content database.</td>
        </tr>
    </table>
    <table class="spcdm-primaryTableFull" cellpadding="1">
        <tr>
            <td class="ms-standardheader ms-inputformheader spcdm-halfWidth">Site Collections</td>
        </tr>
        <tr>
            <td class="ms-descriptiontext ms-inputformdescription spcdm-fullWidth">The following site collections are stored in the specified content database.<hr/></td>
        </tr>
        <tr>
            <asp:GridView ID="siteGrid" runat="server" AutoGenerateColumns="false" OnSorting="GridView1_Sorting" 
                AllowSorting="true" OnPageIndexChanging="siteGrid_PageIndexChanging" GridLines="None" CellPadding="5" Visible="false" Width="100%">
                <RowStyle CssClass="ms-vb2" BorderStyle="None" />
                <AlternatingRowStyle CssClass="ms-alternatingstrong" BorderStyle="None" />
                <HeaderStyle BorderStyle="None" HorizontalAlign="Left" CssClass="spcdm-customHeader" />
                <PagerSettings Mode="NextPrevious" Position="Bottom" NextPageText="Next" PreviousPageText="Previous" 
                    NextPageImageUrl="/_admin/SPContentDbMgr/Images/Submit-Next.png" PreviousPageImageUrl="/_admin/SPContentDbMgr/Images/Submit-Prev.png" FirstPageText="First" LastPageText="Last" />
                <PagerStyle HorizontalAlign="Left" VerticalAlign="Bottom" />
                <SortedAscendingHeaderStyle CssClass="spcdm-customHeaderAsc" />
                <SortedDescendingHeaderStyle CssClass="spcdm-customHeaderAsc" />
                <Columns>
                    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                    <asp:HyperLinkField DataTextField="Url" HeaderText="Url" SortExpression="Url" DataNavigateUrlFields="Url" Target="_blank" />
                    <asp:BoundField DataField="Usage" HeaderText="Storage Used" SortExpression="UsageInt" />
                    <asp:HyperLinkField DataTextField="MoveSite" HeaderText="Move Site Collection" DataTextFormatString="{0:G}" 
                        DataNavigateUrlFields="SiteId" DataNavigateUrlFormatString="/_admin/SPContentDbMgr/MoveSPSite.aspx?SiteId={0}" />
                    <asp:BoundField DataField="SiteId" HeaderText="Site ID" Visible="false" />
                    <asp:BoundField DataField="UsageInt" HeaderText="StorageData" SortExpression="UsageInt" Visible="false" />
                </Columns>
                <EmptyDataTemplate><td class="spcdm-noSites">There are no Site Collections in the specified Content Database.</td></EmptyDataTemplate>
            </asp:GridView>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">View Site Collections by Database</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" Visible="true">
    <a href="/_admin/SPContentDbMgr/ViewSPSites.aspx">View Site Collections by Database</a>
</asp:Content>